#include "inputCommand.h"
#include <wiringSerial.h>
#include <unistd.h>
#include <string.h>

int voiceGetCommand(struct InputCommander *voicer)
{
	int nread;
	memset(voicer->command,'\0',sizeof(voicer->command));
	if((nread = read(voicer->fd,voicer->command,sizeof(voicer->command))) == -1){
			printf("USARAT FOR VOICE TIME\n");
	}
	return nread;
}
int voiceInit(struct InputCommander *voicer)
{
	if((voicer->fd = serialOpen("/dev/ttyAMA0",9600)) == -1 ){
			printf("USARAT FOR VOICE INIT ERROR\n");
			return -1;
	}
	return 0;
}


input voicContrl = {
	.voicesName = "voice",
	.command = {'\0'},
	.init = voiceInit,
	.getCommand = voiceGetCommand,
	.log = {'\0'},
	.next = NULL
};
input *addVoicContrlToInputLink(input *phead)
{
	if(phead != NULL) voicContrl.next = phead;
	return &voicContrl;
}